//
//  BKWidigitView.m
//  bestkeep
//
//  Created by windCould on 17/1/11.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BKWidigitView.h"
#import "BKWidigitSignalView.h"
@interface BKWidigitView ()



@end


@implementation BKWidigitView

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    CGFloat kWidth = frame.size.width - 16.0f;
    CGFloat kHeight = frame.size.height;
    
    if (self) {
        
        BKWidigitSignalView *functionViewFirst = [[BKWidigitSignalView alloc] initWithFrame:CGRectMake(0, 0, kWidth/4.0f, kHeight)];
        functionViewFirst.iconImageView.image = [UIImage imageNamed:@"组-2Widget"];
        functionViewFirst.nameLabel.text = @"手机充值";
        [self addSubview:functionViewFirst];
        
        BKWidigitSignalView *functionViewSecond = [[BKWidigitSignalView alloc] initWithFrame:CGRectMake(kWidth/4.0f, 0, kWidth/4.0f, kHeight)];
        functionViewSecond.iconImageView.image = [UIImage imageNamed:@"组-3Widget"];
        functionViewSecond.nameLabel.text = @"通知中心";
        [self addSubview:functionViewSecond];
        
        BKWidigitSignalView *functionViewThrid = [[BKWidigitSignalView alloc] initWithFrame:CGRectMake(kWidth/2.0f, 0, kWidth/4.0f, kHeight)];
        functionViewThrid.iconImageView.image = [UIImage imageNamed:@"组-1Widget"];
        functionViewThrid.nameLabel.text = @"今日签到";
        [self addSubview:functionViewThrid];
        
        BKWidigitSignalView *functionViewFourth = [[BKWidigitSignalView alloc] initWithFrame:CGRectMake(kWidth/4.0f*3.0f, 0, kWidth/4.0f, kHeight)];
        functionViewFourth.iconImageView.image = [UIImage imageNamed:@"组-4Widget"];
        functionViewFourth.nameLabel.text = @"我的收藏";
        [self addSubview:functionViewFourth];
        self.userInteractionEnabled = YES;
        
        for (int i = 0; i < 4; i++) {
            //UIBarButtonItem *leftButton = [[UIBarButtonItem alloc]initWithCustomView:button];
            //添加按钮到BarButton
            UIButton *Button = [UIButton buttonWithType:UIButtonTypeCustom];
            Button.tag = i + 1993;
            [Button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
            [Button setFrame:CGRectMake(i*kWidth/4.0f, 0, kWidth/4.0f, kHeight)];
            [self addSubview:Button];
        }
        
    }
    return self;
}

- (void)buttonAction:(UIButton *)sender {
    
    if ([self.myDelegate respondsToSelector:@selector(clickWidigitFunctionBtnWithIndex:)]) {
        
        [self.myDelegate clickWidigitFunctionBtnWithIndex:sender.tag - 1993];
    }
}


@end
